<template>
  <div class="app-container">
    <div class="head-container">
      <el-select class="filter-item" style="width: 300px;" prop="bankId" v-model="bankId" clearable filterable placeholder="请选择题库">
        <el-option
          v-for="item in bankList"
          :key="item.id"
          :label="item.bankName"
          :value="item.id">
        </el-option>
      </el-select>
      <el-button class="filter-item" size="mini" type="success" icon="el-icon-search" @click="init">搜索</el-button>
    </div>
    <el-table v-loading="loading" :data="data" ref="table" size="small" style="width: 100%;" border>
      <el-table-column
        type="index"
        label="序号"
        align="center"
        width="60">
      </el-table-column>
      <el-table-column prop="bankName" label="题库名称" align="center"/>
      <el-table-column prop="checkNum" label="检测人数"  align="center"/>
      <el-table-column prop="avgScore" label="平均成绩" align="center"/>
      <el-table-column label="最近一次检测时间" align="center">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.lastTestTime) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" width="150" align="center">
        <template slot-scope="scope">
          <el-button size="mini" type="primary" icon="el-icon-edit" @click="showDetails(scope.row)">成绩排名</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      :total="total"
      :current-page="page + 1"
      style="margin-top: 8px;"
      layout="total, prev, pager, next, sizes"
      @size-change="sizeChange"
      @current-change="pageChange"/>
      <rank-from ref="rkForm"></rank-from>
  </div>
</template>

<script>
  import initData from '@/mixins/initData'
  import rankFrom from './rankFrom'
  import { parseTime } from '@/utils/index'
  import { getBankList } from '@/api/business/gradeMan'
  export default {
    components: { rankFrom },
    mixins: [initData],
    data() {
      return {
        loading: false,
        delLoading: false,
        userName: '',
        bankList:[],
        bankId: ''
      }
    },
    created() {
      this.$nextTick(() => {
        this.init()
        this.bankLs()
      })
    },
    methods: {
      parseTime,
      beforeInit() {
        this.url = 'practice/type-check-list'
        this.params = {
          page: this.page,
          size: this.size,
          bankId: this.bankId
        }
        return true
      },
      bankLs() {
        getBankList().then(res=>{
        	if(res!='' && res!=null){
        		this.bankList=res;
        	}
        }).catch(res=>{

        })
      },
      showDetails(row) {
        this.$refs.rkForm.dialog = true
        this.$refs.rkForm.bankId=row.id;
      }
    }
  }
</script>

<style scoped>

</style>
